﻿using JzSport.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JzSport.Api
{
    /// <summary>
    /// 修改名称
    /// </summary>
    class ChangeNameAction : AuthPostAction<Params.ChangeNameParams,
        Results.ChangeNameResult>
    {
        protected override ActionResult<Results.ChangeNameResult> OnExecute(ActionContext context, SysParameters sysParameters,
            Params.ChangeNameParams opParams)
        {
            ServiceResult<string> serviceResult = new AccountService().ChangeName(context.AccountId,
                opParams.Name);

            Results.ChangeNameResult actionResult = new Results.ChangeNameResult();
            if (serviceResult.ErrorCode == ErrorCode.NoError)
            {

                return new ActionResult<Results.ChangeNameResult>(true, serviceResult.ErrorCode,
                    ErrorCode.ToString(serviceResult.ErrorCode), actionResult);
            }
            return new ActionResult<Results.ChangeNameResult>(false, serviceResult.ErrorCode,
                    ErrorCode.ToString(serviceResult.ErrorCode), actionResult);
        }
    }
}
